Manages the nodes available in the component. More...
Public Member Functions | |
Node * | create () |
Node * | createOrRetrieve (const std::string_view &name) |
Node * | get (const std::string_view &name) const |
Node * | getByIndex (unsigned int index) const |
void | rename (const std::string_view ¤tName, const std::string_view &newName) |
void | erase (const std::string_view &name) |
Manages the nodes available in the component.
At all times, the manager is responsible for memory returned. External code should never free it.
The manager is the entry point when starting a graph. By creating a node through createOrRetrieve, a local root can be obtained.
To construct a graph, it is either possible to instanciate a new node through the Manager and add it to the graph, or call graph managing functions on an existing node.
Node* nkGraphics::NodeManager::create | ( | ) |
Creates a node.
This version of the function will use an internal counter to create names shaped like "Node_0", "Node_1". The counter gets incremented as the function gets called.
Node* nkGraphics::NodeManager::createOrRetrieve | ( | const std::string_view & | name | ) |
Creates if unavailable, or retrieves if available, a node.
name | The name of the node to retrieve. |
Node* nkGraphics::NodeManager::get | ( | const std::string_view & | name | ) | const |
Retrieves an existing node.
name | The name of the node wanted. |
Node* nkGraphics::NodeManager::getByIndex | ( | unsigned int | index | ) | const |
Retrieves a node given an index. Note that as the internal memory is changed, an index can map to different nodes over different calls. Mainly used to loop over all nodes in one go.
index | The index of the node to retrieve. |
void nkGraphics::NodeManager::rename | ( | const std::string_view & | currentName, |
const std::string_view & | newName | ||
) |
Renames a node, changing both its name and the way it is accessed through the manager.
currentName | The name of the node to rename. |
newName | The name to attach. |
void nkGraphics::NodeManager::erase | ( | const std::string_view & | name | ) |
Erases and frees the memory of a node.
name | The name of the node to erase. |